/*
 * system_exception.h
 *
 *  Created on: 2008-12-31
 *      Author: fanliangliang
 */

#ifndef SYSTEM_EXCEPTION_H_
#define SYSTEM_EXCEPTION_H_

#include "config.h"
#include <string>
#include <exception>

BEGIN_NAMESPACE_TOXIC

using std::string;
using std::exception;

namespace detail {

	unsigned long lastError();
	unsigned long lastNetworkError();
	string errorString(unsigned long id);

} // namespace detail


class SystemException : public exception {
public:
	SystemException() throw()
	:_what(detail::errorString(detail::lastError())) {
	}

	explicit SystemException(unsigned long id) throw()
	:_what(detail::errorString(id)) {
	}

	explicit SystemException(const string& what) throw()
	:_what(what) {
	}

	virtual ~SystemException() throw() {
	}

	virtual const char* what() const throw() {
		return _what.c_str();
	}

private:
	string _what;
};

END_NAMESPACE_TOXIC

#endif /* SYSTEM_EXCEPTION_H_ */
